package cn.com.bluemoon.daps.standard.mapper;

import cn.com.bluemoon.daps.standard.entity.DapSystemCategory;
import cn.com.bluemoon.daps.standard.vo.SysTopicCategorySimpleVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标准-分类表 Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2020-08-03
 */
@Repository
public interface DapSystemCategoryMapper extends BaseMapper<DapSystemCategory> {

    @Select("SELECT a.code_name AS topic,\n" +
            "       b.code_name AS firstC,\n" +
            "       c.code_name AS secondC,\n" +
            "       d.code_name AS thirdC\n" +
            "FROM dap_system_category a\n" +
            "         LEFT JOIN dap_system_category b ON b.parent_id = a.id\n" +
            "         LEFT JOIN dap_system_category c ON c.parent_id = b.id\n" +
            "         LEFT JOIN dap_system_category d ON d.parent_id = c.id\n" +
            "where a.bm_status = 1\n" +
            "  and a.parent_id is null")
    List<SysTopicCategorySimpleVo> topicCategories();
}
